﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;

namespace DCCMS.Web
{
    public class Global : System.Web.HttpApplication
    {
        public static string CssPath
        {
            get
            {
                return DCCMS.Common.Config.StyleConfig.CssFolder;
            }
        }
        public static string AppTitle
        {
            get
            {
                return DCCMS.Common.Config.GlobalConfig.ProjectName;
            }
        }
        public static string AppSubTitle
        {
            get
            {
                return DCCMS.Common.Config.GlobalConfig.ProjectSubTitle;
            }
        }
        public static string SearchKeyWords
        {
            get
            {
                return DCCMS.Common.Config.GlobalConfig.SearchKeyWords;
            }
        }

        protected void Application_Start(object sender, EventArgs e)
        {

        }

        protected void Session_Start(object sender, EventArgs e)
        {

        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {

        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {
            // Code that runs when an unhandled error occurs
            //string cacheKey = HttpContext.Current.Session.SessionID;
            //if (HttpContext.Current.Cache[cacheKey] == null)
            //{
            //    HttpContext.Current.Cache.Add(cacheKey, 1, null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(10), System.Web.Caching.CacheItemPriority.Normal, null);
            //}
            //else
            //{
            //    int index = (int)HttpContext.Current.Cache[cacheKey] + 1;
            //    HttpContext.Current.Cache.Add(cacheKey, index, null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(10), System.Web.Caching.CacheItemPriority.Normal, null);
            //}
            //if ((int)HttpContext.Current.Cache[cacheKey] <= 5)
            //{
            //    Response.Redirect("/Error.aspx?");
            //}
        }

        protected void Session_End(object sender, EventArgs e)
        {

        }

        protected void Application_End(object sender, EventArgs e)
        {

        }
    }
}